|
|
@@ -166,16 +166,21 @@ describe LiquidInterpolatable::Filters do
|
166
|
166
|
end
|
167
|
167
|
end
|
168
|
168
|
|
169
|
|
- describe 'regex_replace' do
|
170
|
|
- it 'should replace all occurences of a string using regex' do
|
171
|
|
- expect(@filter.regex_replace('foobar foobar', /\S+bar/, 'foobaz')).to eq('foobaz foobaz')
|
|
169
|
+ describe 'regex replace' do
|
|
170
|
+ let(:agent) { Agents::InterpolatableAgent.new(name: "test") }
|
|
171
|
+
|
|
172
|
+ it 'should replace the first occurrence of a string using regex' do
|
|
173
|
+ agent.interpolation_context['something'] = 'foobar foobar'
|
|
174
|
+ agent.options['cleaned'] = '{{ something | regex_replace_first: "\S+bar", "foobaz" }}'
|
|
175
|
+ expect(agent.interpolated['cleaned']).to eq('foobaz foobar')
|
172
|
176
|
end
|
173
|
|
- end
|
174
|
177
|
|
175
|
|
- describe 'regex_replace_first' do
|
176
|
|
- it 'should replace the first occurences of a string using regex' do
|
177
|
|
- expect(@filter.regex_replace_first('foobar foobar', /\S+bar/, 'foobaz')).to eq('foobaz foobar')
|
|
178
|
+ it 'should replace the all occurrences of a string using regex' do
|
|
179
|
+ agent.interpolation_context['something'] = 'foobar foobar'
|
|
180
|
+ agent.options['cleaned'] = '{{ something | regex_replace: "\S+bar", "foobaz" }}'
|
|
181
|
+ expect(agent.interpolated['cleaned']).to eq('foobaz foobaz')
|
178
|
182
|
end
|
|
183
|
+
|
179
|
184
|
end
|
180
|
185
|
|
181
|
186
|
end
|